package com.redpacketcover.rc.base;

public abstract class BasicPresenter<V extends BasicView, M extends BasicMode> implements BasicIPresenter<V> {

    public V mView;

    public M mMode;

    public abstract M getModeInstance();


    /**
     * V与P形成依赖
     */
    @Override
    public void attachView(V mvpView) {
        this.mView = mvpView;
        mMode = getModeInstance();
    }

    /**
     * P释放V
     */
    @Override
    public void detachView() {
        this.mView = null;
        if (mMode != null) {
            mMode.onUnSubscribe();
            mMode = null;
        }

    }

}
